import type { CategoryList } from "./categoryModel";
import type { UploadUserFile } from "element-plus";

export interface GetSpuListParams {
  page: number;
  limit: number;
  category3Id: number;
}

/**
 * "data": {
    "records": [
      {
        "id": 4603,
        "spuName": "223",
        "description": "4322121324",
        "category3Id": 1,
        "tmId": 18226,
        "spuSaleAttrList": null,
        "spuImageList": null
      },
      {
        "id": 4569,
        "spuName": "RTX3060",
        "description": "华硕天选笔记本",
        "category3Id": 1,
        "tmId": 25,
        "spuSaleAttrList": null,
        "spuImageList": null
      }
    ],
    "total": 2,
    "size": 3,
    "current": 1,
    "searchCount": true,
    "pages": 1
  },
 */

// 公共类型
interface CommonSpu {
  spuName: string; // spu名称
  description: string; // spu描述
  tmId: number; // 品牌id
}

export interface SpuItem extends CommonSpu {
  id: number;
  category3Id: number; // 三级分类id
}

export type SpuList = SpuItem[];

export interface GetSpuListResponse {
  records: SpuList;
  total: number;
}

export type BaseSaleAttrList = CategoryList;

//****************************************** */

export interface AllSpuSaleAttrValueItem {
  baseSaleAttrId: number;
  id?: 0;
  saleAttrValueName: string;
  spuId?: 0;
}

export type AllSpuSaleAttrValueList = AllSpuSaleAttrValueItem[];

export interface AllSpuSaleAttrItem {
  baseSaleAttrId: number;
  saleAttrName: string;
  id?: 0;
  spuId?: 0;
  isShowEdit?: boolean;
  spuSaleAttrValueList: AllSpuSaleAttrValueList;
}

export type AllSpuSaleAttrList = AllSpuSaleAttrItem[];

export interface AllSpuImageItem {
  imgName: string;
  imgUrl: string;
  isDefault?: string;
}

export type AllSpuImageList<T = AllSpuImageItem | UploadUserFile> = Array<T>;

export interface AllSpuItem<T = AllSpuImageItem | UploadUserFile> {
  id?: number;
  spuName: string;
  description: string;
  category3Id?: number;
  tmId?: number;
  spuImageList: AllSpuImageList<T>;
  spuSaleAttrList: AllSpuSaleAttrList;
}

/**
 * 
 * {
  "category3Id": 0,
  "description": "string",
  "id": 0,
  "spuImageList": [
    {
      "id": 0,
      "imgName": "string",
      "imgUrl": "string",
      "spuId": 0
    }
  ],
  "spuName": "string",
  "spuSaleAttrList": [
    {
      "baseSaleAttrId": 0,
      "id": 0,
      "saleAttrName": "string",
      "spuId": 0,
      "spuSaleAttrValueList": [
        {
          "baseSaleAttrId": 0,
          "id": 0,
          "isChecked": "string",
          "saleAttrName": "string",
          "saleAttrValueName": "string",
          "spuId": 0
        }
      ]
    }
  ],
  "tmId": 0
}
 */
